package utils;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
    //连接数据库

public class DBConn {

    public static Connection getConnection(){
        Connection connection=null;
        String url="jdbc:mysql://localhost:3306/test?"+"useSSL=false&serverTimezone=CST&characterEnconding=UTF-8";
        String user="root";
        String password="123456";

        try {
            Class.forName("com.mysql.cj.jdbc.Driver");//加载驱动
             connection = DriverManager.getConnection(url, user, password);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("数据库连接异常");
        }
        return connection;

    }


}
